﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.OracleClient;
using Xiaov.SmartWeb.Model;

namespace Xiaov.SmartWeb.Application.HXZB
{
    public partial class Zjtz : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            PM_Filter();
            if (!Page.IsPostBack)
            {
                BindDDL();
            }         
        }

        protected void BindDDL()
        {
            try
            {
                Statistics.UI.DDL.BindDDL(ddl_Owner, ddl_Year, ddl_Month, PUser.USERDEPT, true);
            }
            catch (Exception ex)
            {

            }
            //从cookies获取默认值
            if (Request.Cookies["UserSelectInfo"] != null)
            {
                ddl_Owner.SelectedValue = Request.Cookies["UserSelectInfo"]["DW"];
                ddl_Year.SelectedValue = Request.Cookies["UserSelectInfo"]["NF"];
                ddl_Month.SelectedValue = Request.Cookies["UserSelectInfo"]["YF"];
            }
        }

        protected void btnQuery_Click(object sender, EventArgs e)
        {
            //将年份、月份、单位、发送给客户端
            HttpCookie cookies = new HttpCookie("UserSelectInfo");
            cookies.Values["DW"] = ddl_Owner.SelectedValue;
            cookies.Values["NF"] = ddl_Year.SelectedValue;
            cookies.Values["YF"] = ddl_Month.SelectedValue;
            cookies.Expires = DateTime.MaxValue;
            HttpContext.Current.Response.Cookies.Add(cookies);
        }

        protected void btnGen_Click(object sender, EventArgs e)
        {
            //调用过程             
           OracleParameter[] parameters ={     
                   new OracleParameter("p_nf",OracleType.VarChar,100)
                   };
           parameters[0].Value = ddl_Year.SelectedValue;
           OracleDataReader dr=  Maticsoft.DBUtility.DbHelperOra.RunProcedure("P_TZ_GENZJTZ", parameters);
           dr.Close();
        }
    }
}